package org.eztouch.common.base;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.mapper.Wrapper;

public abstract class BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	@TableId(type = IdType.ID_WORKER)
	protected Long tid;
	protected Long createBy;
	protected Date createTime;
	protected Integer isDelete;
	
	/**
	 * 构建查询条件Wrapper实例
	 */
	public abstract Wrapper<? extends BaseEntity> bindingQueryWrapper();
	
	
	public Integer getIsDelete() {
		return isDelete;
	}


	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}


	/**
	 * @return the createBy
	 */
	public Long getCreateBy() {
		return createBy;
	}

	/**
	 * @param createBy
	 *            the createBy to set
	 */
	public void setCreateBy(Long createBy) {
		this.createBy = createBy;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @param createTime
	 *            the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


	public Long getTid() {
		return tid;
	}


	public void setTid(Long tid) {
		this.tid = tid;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (createBy ^ (createBy >>> 32));
		result = prime * result
				+ ((createTime == null) ? 0 : createTime.hashCode());
		result = prime * result + isDelete;
		result = prime * result + (int) (tid ^ (tid >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BaseEntity other = (BaseEntity) obj;
		if (createBy != other.createBy)
			return false;
		if (createTime == null) {
			if (other.createTime != null)
				return false;
		} else if (!createTime.equals(other.createTime))
			return false;
		if (isDelete != other.isDelete)
			return false;
		if (tid != other.tid)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "BaseEntity [tid=" + tid + ", createBy=" + createBy
				+ ", createTime=" + createTime + "]";
	}
	
}
